a =[1,2,4,6,8,9]
s = len(a)
for i in range(s)*2:
    print(i)



stack=[]
_len=len(a)
result=[-1]*_len
for i in range(_len)*2:
    while stack!=[] and a[i]>a[stack[-1]]:
        result[stack.pop()]=a[i]
    stack.append(i)

